package com.iw.adoms.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;

import com.iw.core.orm.hibernate.BaseEntity;

@Entity
@Table(name = "goods")
@JsonIgnoreProperties({ "marchandise", "department", "new", "hibernateLazyInitializer", "order" })
public class Goods extends BaseEntity {

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "marchandise_id")
	private Marchandise marchandise; // 所属商品

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "storage_batch_id")
	private StorageBatch storageBatch; // 所属入库的批次

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "department_id")
	private Department department; // 所属部门

	private Date produceDate; // 生产日期

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "order_id")
	private Order order; // 所属订单

	private String salesState; // 销售状态

	private String state;

	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "qr_code_id")
	private QrGoodsCode qrCode;// 货物二维码

	private String memo; // 备注

	public Marchandise getMarchandise() {
		return marchandise;
	}

	public void setMarchandise(Marchandise marchandise) {
		this.marchandise = marchandise;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	public Order getOrder() {
		return order;
	}

	public void setOrder(Order order) {
		this.order = order;
	}

	public String getSalesState() {
		return salesState;
	}

	public void setSalesState(String salesState) {
		this.salesState = salesState;
	}

	public QrGoodsCode getQrCode() {
		return qrCode;
	}

	public void setQrCode(QrGoodsCode qrCode) {
		this.qrCode = qrCode;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public StorageBatch getStorageBatch() {
		return storageBatch;
	}

	public void setStorageBatch(StorageBatch storageBatch) {
		this.storageBatch = storageBatch;
	}

	public Date getProduceDate() {
		return produceDate;
	}

	public void setProduceDate(Date produceDate) {
		this.produceDate = produceDate;
	}

	public Goods clone(Goods o) {
		Goods g = new Goods();
		g.setDepartment(o.getDepartment());
		g.setInsertTime(new Date());
		g.setMarchandise(o.getMarchandise());
		g.setMemo(o.getMemo());
		g.setOrder(o.getOrder());
		g.setQrCode(o.getQrCode());
		g.setSalesState(o.getSalesState());
		g.setState(o.getState());
		g.setProduceDate(o.getProduceDate());
		return g;
	}

}